import axios from 'axios'
import * as types from './action-types'

export const changeIsLogin = (bol) => ({
  type: types['CHANGE_ISLOGIN'],
  bol
})

export const loginInAction = (account, password) => {
  return (dispatch) => {
    axios.get('/api/login.json', {
      params: {
        userName: account,
        password
      }
    }).then(res => {
      const result = res.data
      if (result.success) {
        dispatch(changeIsLogin(true))
      }
    })
  }
}